﻿using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class SceneControl : MonoBehaviour {

    public bool startPaused = true;

    public Button playButton;
    public Button pauseButton;
    public Color activeColor;
    public Color normalColor;
    
    
    IEnumerator Start () {
        yield return null;
        if (startPaused) {
            OnPauseClicked ();
        }
    }
    
    public void OnPlayClicked () {
        Time.timeScale = 1;
        ColorBlock playButtonColors = playButton.colors;
        playButtonColors.normalColor = activeColor;
        playButton.colors = playButtonColors;
        
        ColorBlock pauseButtonColors = pauseButton.colors;
        pauseButtonColors.normalColor = normalColor;
        pauseButton.colors = pauseButtonColors;
    }


    public void OnPauseClicked () {
        Time.timeScale = 0;
        
        ColorBlock pauseButtonColors = pauseButton.colors;
        pauseButtonColors.normalColor = activeColor;
        pauseButton.colors = pauseButtonColors;
        
        ColorBlock playButtonColors = playButton.colors;
        playButtonColors.normalColor = normalColor;
        playButton.colors = playButtonColors;
    }


    public void OnReloadScene () {
        SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
    }


    public void OnCloseClicked () {
        Application.Quit ();
    }

}